<?php if ( ! defined('BASEPATH')) exit('No direct script access allowed');

class Home extends OC_Controller {
    function __construct()
    {
        parent::__construct();
        $this->load->model('home/home_model');
        $this->load->model('events/events_model');
        $this->load->model('recipes/recipe_model','rm');
        $this->load->helper('text');
    }

    function _remap($method, $params = array())
    {
        parent::_remap($method, $params);

        if (method_exists($this, $method))
            return call_user_func_array(array($this, $method), $params);
        else
            show_404();
    }

    function init_header()
    {
        $this->header['meta'] = array(
            'description' => array('name' => 'description', 'content' => 'Haan Kreasi Ibu Juara'),
            'keywords' => array('name' => 'keywords', 'content' => 'Haan Kreasi Ibu Juara, recipes, kreasi ibu, kreatif, sajian  kreatif'),
        );
    }

    public function index()
    {
        $this->init_header();
        $this->header['top_nav']        = 'home';
        $this->header['banners']        = $this->home_model->get_banners();
        $this->header['articles']       = $this->home_model->get_articles();
        $this->header['widget_home']    = $this->home_model->get_widget();
        $this->header['widget_footer']  = $this->home_model->get_widget(2);
        $this->header['event_home']     = $this->home_model->get_event();
        $this->header['recipes_home']   = $this->home_model->get_recipes();
        $this->header['recipes2_home']  = $this->home_model->get_recipes2();
        $this->header['produk_home']    = $this->home_model->get_produk();
        $this->header['socmed_home']    = $this->home_model->get_socmed();
        $this->header['get_cat_produk'] = $this->home_model->get_category('category_product','cp_id');
        $this->header['get_cat_resep']  = $this->home_model->get_category('category_recipes','cr_id');
        $this->header['get_cat_article']= $this->home_model->get_category('category_article','ca_id');
        $this->view('home/home_view');
    }

    public function result()
    {
        $this->init_header();
        $this->header['top_nav']        = 'result for '.$this->input->post('keyword');
        $this->header['articles']       = $this->home_model->get_articles();
        $this->header['widget_home']    = $this->home_model->get_widget();
        $this->header['widget_footer']  = $this->home_model->get_widget(2);
        $this->header['socmed_home']    = $this->home_model->get_socmed(); 
        $this->header['res_products']   = $this->home_model->get_result_products($this->input->post('keyword'));
        $this->header['res_recipes']    = $this->home_model->get_result_recipes($this->input->post('keyword'));
        $this->header['res_events']     = $this->home_model->get_result_events($this->input->post('keyword'));
        $this->header['res_articles']   = $this->home_model->get_result_articles($this->input->post('keyword'));
        $this->header['get_cat_produk'] = $this->home_model->get_category('category_product','cp_id');
        $this->header['get_cat_resep']  = $this->home_model->get_category('category_recipes','cr_id');
        $this->header['get_cat_article']= $this->home_model->get_category('category_article','ca_id');
        $this->header['recent_articles']    = $this->events_model->get_recent_articles();
        $this->header['recent_products']    = $this->events_model->get_recent_products();
        $this->view('home/result_view');
    }

}

/* End of file home.php */
/* Location: ./applications/module_front/home/controllers/home.php */